package com.heima.sc.user.controller;

import com.heima.sc.user.service.UserService;
import com.itheima.sc.pojo.User;
import com.itheima.sc.response.UserOrderDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/{username}")
    public User findOne(@PathVariable("username")String username){
        return userService.findOne(username);
    }

    @GetMapping
    public List<UserOrderDTO> findUserOrders(){
        return userService.findUserOrders();
    }
}
